package cn.zs.supply;

//import org.mybatis.spring.annotation.MapperScan;

import cn.zs.supply.web.filter.HeaderFilter;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.context.annotation.PropertySource;
import org.springframework.scheduling.annotation.EnableAsync;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
import javax.servlet.Filter;
@EnableDiscoveryClient
@EnableFeignClients(basePackages = {"cn.zs.supply.feignClient"})
@ComponentScan(basePackages = {"cn.zs.supply","cn.zs.supply.web.filter"})
@PropertySource("classpath:application.${APP_ENV:DEV}.properties")
@EnableCaching
@EnableAsync
@EnableSwagger2
@SpringBootApplication
@EnableAspectJAutoProxy(proxyTargetClass=true)
public class WebApplication {
    public static void main(String[] args) {
        SpringApplication.run(WebApplication.class, args);
    }
	@Bean
    public Filter headerFilter(){
        return new HeaderFilter();
    }
	@Bean
    public FilterRegistrationBean headerFilterRegistration() {
		FilterRegistrationBean registration = new FilterRegistrationBean();
        registration.setFilter(headerFilter());
        registration.addUrlPatterns("/*");
        registration.setName("headerFilter");

        return registration;
    }
}